package com.guchenbo.study.mvc.view;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(GcbViewProperties.class)
public class GcbViewConfiguration {
    private GcbViewProperties gcbViewProperties;

    public GcbViewConfiguration(GcbViewProperties gcbViewProperties) {
        /*
        通过构造器注入
         */
        this.gcbViewProperties = gcbViewProperties;
    }

    @Bean
    public GcbViewResolver gcbViewResolver() {
        GcbViewResolver viewResolver = new GcbViewResolver();
        viewResolver.setViewClass(GcbView.class);
        viewResolver.setPrefix(gcbViewProperties.getPrefix());
        viewResolver.setSuffix(gcbViewProperties.getSuffix());
        return viewResolver;
    }
}
